from numpy import NaN
import pandas as pd

def init_data(login):
    return {
        'login': login,
        'commit': 0,
        'issue': 0,
        'pullrequest': 0,
        'issuecomment': 0,
        'commitcomment': 0,
        'following': 0,
        'followers': 0,
        'contri': 0,
    }

def base_preprocess(data_out, path, login_param, param_name):
    data_in = pd.read_csv(path)
    for index,row_data in data_in.iterrows():
        if not pd.isnull(row_data[login_param]):
            login = row_data[login_param]
        else:
            continue
        if login not in data_out:
            data_out[login] = init_data(login)
        data_out[login][param_name] = data_out[login][param_name]+1

def hash_to_DataFrame(data_hash):
    data_list = [v for v in data_hash.values()]
    return pd.DataFrame(data_list)